<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html;charset=UTF-8" isELIgnored="false"%>
<%@ page import="com.example.bbs.model.User" %>
<%@ page import="com.example.bbs.model.Block" %>
<%@ page import="com.example.bbs.utils.TimeUtil" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML>

<html>
<head>
	<title>帖子详情</title>
	<meta charset="utf-8"/>
	<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
	<style>
		.container{
			width:1000px;
			margin:0px auto;
		}
		.content{
			clear:both;
		}
		
		table{
			margin:0px auto;
			border-collapse:collapse;
			margin-top:10px;
		}
		
		tr td:nth-of-type(1){
			width:200px;
			padding:15px;
		}
		
		tr td:nth-of-type(2){
			width:500px;
			position:relative;
		}
		
		tr td:nth-of-type(2) div:nth-of-type(1){
			border-bottom: 1px dashed black;
			margin-bottom:10px;
		}
		
		tr td:nth-of-type(2) div:nth-of-type(3){
			position:absolute;
			bottom:5px;
			right:5px;
		}
		
		td{
			vertical-align:top;
		}
		
		.right{
			float:right;
		}
		
		textarea{
			width:100%;
			height:80px;
			font-size:16px;
			margin-bottom:10px;
		}
		
	</style>
</head>

<body>
<c:if test="${empty sessionScope.loginUser}">
	<c:set var="fail" scope="session" value="请先登录"></c:set>
	<c:redirect url="login.jsp"></c:redirect>
</c:if>

	<div class="container">
		<jsp:include page="head.jsp" flush="true" />
		
		<div class="content">
			<div>
				当前位置: <a href="/bbs/posts.action?bid=${block.blockId}">${block.blockName}</a> >> <a href="/bbs/postDetail.action?pid=${post.postId}">${post.postTitle}</a>
			</div>
			
			
			<table border="1">
				<tr>
					<td>
						<div>${postUser.userName}</div>
						<div><img src="${postUser.userHead}" alt="用户头像"/></div>
						<div>UID: ${postUser.userId}</div>
						<div>发帖: ${postUser.postNumber}</div>
						<div>注册时间: <fmt:formatDate type="both" dateStyle="medium" timeStyle="medium" value="${postUser.createTime}" /></div>
						<div>最后登录: <fmt:formatDate type="both" dateStyle="medium" timeStyle="medium" value="${postUser.loginTime}" /></div>
					</td>
					<td>
						<div>发表于: <fmt:formatDate type="both" dateStyle="medium" timeStyle="medium" value="${post.postTime}" /><span class="right">#楼主</span></div>
						<div>${post.postContent}</div>
						<div></div>
					</td>
				</tr>

				<c:forEach  items="${replys}"  var="reply"  varStatus="status">
					<tr>
						<td>
							<div>${users[status.index].userName}</div>
							<div><img src="${users[status.index].userHead}" alt="用户头像"/></div>
							<div>UID: ${users[status.index].userId}</div>
							<div>发帖: ${users[status.index].postNumber}</div>
							<div>注册时间: <fmt:formatDate type="both" dateStyle="medium" timeStyle="medium" value="${users[status.index].createTime}" /></div>
							<div>最后登录: <fmt:formatDate type="both" dateStyle="medium" timeStyle="medium" value="${users[status.index].loginTime}" /></div>
						</td>
						<td>
							<div>发表于: <fmt:formatDate type="both" dateStyle="medium" timeStyle="medium" value="${reply.replyTime}" /><span class="right">#${status.count}楼</span></div>
							<div>${reply.content}</div>
							<c:if test="${sessionScope.loginUser.userId == users[status.index].userId}">
								<div><a href="/bbs/delete.action?replyId=${reply.replyId}&postId=${post.postId}">删除</a></div>
							</c:if>
							<div></div>
						</td>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="2">
						<form action="/bbs/doReply.action" method="post">
							<!-- 隐藏域:保存当前回复帖子对应的帖子ID -->
							<input type="hidden" name="pid" id="inputPid" value="${post.postId}"/>
							<textarea name="content" id="inputContent"></textarea>
							<input value="发表回复"  onclick="doReply()" type="submit"/>
						</form>
					</td>
				</tr>
			</table>
			
		
		</div>
	</div>
<script>
	function doReply(){
		var vue = new Vue({
			el:".container",
			data:{

			}
		});
	}
</script>
</body>
</html>
